package com.ruoyi.map.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.map.domain.FhMapBaitrecommend;
import com.ruoyi.map.service.IFhMapBaitrecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 鱼饵推荐管理Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/map/baitrecommend")
public class FhMapBaitrecommendController extends BaseController
{
    @Autowired
    private IFhMapBaitrecommendService fhMapBaitrecommendService;

    /**
     * 查询鱼饵推荐管理列表
     */
    @PreAuthorize("@ss.hasPermi('map:baitrecommend:list')")
    @GetMapping("/list")
    public TableDataInfo list(FhMapBaitrecommend fhMapBaitrecommend)
    {
        startPage();
        List<FhMapBaitrecommend> list = fhMapBaitrecommendService.selectFhMapBaitrecommendList(fhMapBaitrecommend);
        return getDataTable(list);
    }

    /**
     * 导出鱼饵推荐管理列表
     */
    @PreAuthorize("@ss.hasPermi('map:baitrecommend:export')")
    @Log(title = "鱼饵推荐管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FhMapBaitrecommend fhMapBaitrecommend) throws IOException {
        List<FhMapBaitrecommend> list = fhMapBaitrecommendService.selectFhMapBaitrecommendList(fhMapBaitrecommend);
        ExcelUtil<FhMapBaitrecommend> util = new ExcelUtil<FhMapBaitrecommend>(FhMapBaitrecommend.class);
        util.exportExcel(response, list, "鱼饵推荐管理数据");
    }

    /**
     * 获取鱼饵推荐管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('map:baitrecommend:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fhMapBaitrecommendService.selectFhMapBaitrecommendById(id));
    }

    /**
     * 新增鱼饵推荐管理
     */
    @PreAuthorize("@ss.hasPermi('map:baitrecommend:add')")
    @Log(title = "鱼饵推荐管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FhMapBaitrecommend fhMapBaitrecommend)
    {
        return toAjax(fhMapBaitrecommendService.insertFhMapBaitrecommend(fhMapBaitrecommend));
    }

    /**
     * 修改鱼饵推荐管理
     */
    @PreAuthorize("@ss.hasPermi('map:baitrecommend:edit')")
    @Log(title = "鱼饵推荐管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FhMapBaitrecommend fhMapBaitrecommend)
    {
        return toAjax(fhMapBaitrecommendService.updateFhMapBaitrecommend(fhMapBaitrecommend));
    }

    /**
     * 删除鱼饵推荐管理
     */
    @PreAuthorize("@ss.hasPermi('map:baitrecommend:remove')")
    @Log(title = "鱼饵推荐管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhMapBaitrecommendService.deleteFhMapBaitrecommendByIds(ids));
    }
}
